<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>

<script>
    const channel = new BroadcastChannel("music");
    channel.addEventListener("message", function (event) {
        console.log('消息',event.data);
    });

    window.addEventListener('pagehide', function (event) {
        if (!event.persisted) {
            localStorage.setItem('music', 0)
        }
    });
</script>

</body>
</html>